<template>
  <div id="app">
    <template v-if="route.path.startsWith('/user')">
      <router-view />
    </template>
    <template v-else>
      <BasicLayout />
    </template>
  </div>
</template>

<script setup lang="ts">
import BasicLayout from "@/layouts/BasicLayout";
import { onMounted } from "vue";
import { useRoute } from "vue-router";
import { useStore } from "vuex"; // ✅ 引入 store

const route = useRoute();
const store = useStore(); // ✅ 获取 store 实例

/**
 * 全局初始化函数，有全局单次调用的代码，都可以写到这里
 */
const doInit = async () => {
  console.log("hello 欢迎来到我的项目");
  // ✅ 应用启动时拉取登录用户信息
  await store.dispatch("user/getLoginUser");
};

onMounted(() => {
  doInit();
});
</script>

<style>
#app {
}
</style>
